<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        li {
            width: 250px;
            height: 30px;
            background-color: antiquewhite;
            margin-top: 60px;
        }
    </style>
</head>

<body>
    <textarea name="" id="" cols="30" rows="10"></textarea>
    <button>发布</button>
    <ul>
    </ul>
    <a
        href="https://www.bilibili.com/video/BV1Sy4y1C7ha/?p=234&spm_id_from=pageDriver&vd_source=480c28921b1b6c12cb33e4a6f0a94947 ">视频链接</a>
    <script>
        //获取元素
        let btn = document.querySelector('button');
        let text = document.querySelector('textarea');
        let ul = document.querySelector('ul');
        //注册事件
        btn.onclick = function () {
            if (text.value == '') {
                alert('您还没有输入内容');
                return false;
            } else {
                //创建元素
                let li = document.createElement('li') + '<a href="javascript:;">删除<a/>';
                //先有li才能赋值
                li.innerHTML = text.value;
                //添加元素
                // ul.appendChild(li);
                ul.insertBefore(li, ul.children[0]);
            }
        }
    </script>
</body>

</html>